#include "Riostream.h"
void writeroot() {

                ifstream in; in.open("toy_Ang.dat");
double phi0,phi1,phi2,theta0,theta1,theta2;

                Int_t nlines = 0;
                TFile *f = new TFile("toy_Ang.root","RECREATE");
                TTree *t_data = new TTree("t_data","test t_data");
t_data->Branch("theta0",&theta0,"theta0/D");
t_data->Branch("theta1",&theta1,"theta1/D");
t_data->Branch("theta2",&theta2,"theta2/D");


t_data->Branch("phi0",&phi0,"phi0/D");
t_data->Branch("phi1",&phi1,"phi1/D");
t_data->Branch("phi2",&phi2,"phi2/D");

  while (1) {
	in>>phi0>>theta0>>phi1>>theta1>>phi2>>theta2;
	if (!in.good()) break;
	t_data->Fill();
	nlines++;
	}
  printf(" found %d points\n",nlines);
  in.close();
  f->Write();
  f->Close();
}
